<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ include file="../../../attr.jsp" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<!doctype html>
<html>
<head>
<meta http-equiv="X-UA-Compatible" content="IE=emulateIE7" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta charset="utf-8">
<link rel="stylesheet" href="${ctx}/css/sapar.css" />
<link rel="stylesheet" type="text/css" href="${ctx}/css/common.css" />
<script type="text/javascript" src="${ctx}/js/jquery.js"></script>
<script type="text/javascript" src="${ctx}/js/sapar.js"></script>
<script type="text/javascript" src="${ctx}/js/WdatePicker.js"></script>
<script type="text/javascript" src="${ctx}/assets/layer/layer.js"></script>
<script type="text/javascript" src="${ctx}/js/ajaxfileupload.js"></script>
<title>投诉与建议</title>
</head>

<body>
    <div id="saper-container">
        <div id="saper-hd"></div>
        <div id="saper-bd">
            <div class="subfiled clearfix">
                <h2>投诉与建议</h2>
            </div>
			<div class="subfiled-content">
	            <form class="saper-form" id="dataForm">
	                <div class="kv-item clearfix">
	                    <label><span class="impInfo">*</span>标题：</label>
	                    <div class="kv-item-content">
	                        <input type="text" placeholder="标题" class="txt_required" name="adviceTitle" value="${advice.adviceTitle}" onkeyup="this.value=this.value.replace(/(^\s*)|(\s*$)/g,'')">
	                    </div>
	                </div>
	                <div class="kv-item clearfix">
	                    <label><span class="impInfo">*</span>对象：</label>
	                    <div class="kv-item-content">
	                        <select id="affsort" name="adviceObject">
	                            <option value="">请选择</option>
	                            <c:if test="${employee != null}">
	                                <c:forEach items="${employee }" var="emp">
	                                    <c:if test="${emp.employeeId != empId }">
	                                    	<option value="${emp.employeeId }">${emp.employeeName }</option>
	                                    </c:if>
	                                    <%-- <option value="${emp.employeeId }">${emp.employeeName }</option> --%>
	                                </c:forEach>
	                            </c:if>
	                        </select>
	                    </div>
	                </div>
	                <div class="kv-item clearfix">
	                    <label><span class="impInfo">*</span>内容：</label>
	                    <div class="kv-item-content">
	                    	<textarea rows="1" cols="10"  placeholder="内容" class="txt_required" name="adviceContent" value="${advice.adviceContent}">
	                    	</textarea>
	                    </div>
	                </div>
	                <div class="buttons">
	                    <a href="javascript:;" class="sapar-btn sapar-btn-recom" id="queding">确定</a>
	                    <%-- <input name="afficheId" type="hidden" value="${affiche.afficheId}"> --%>
	                </div>
	            </form>
            </div>
        </div>
        <div id="saper-ft"></div>
    </div>
    
    
<script type="text/javascript">
$(function(){
	$("#queding").click(function(){
		 var btn = true;
		 $(".txt_required").each(function(){
			 var str =$(this).val();
			 if(isNullOrEmpty(str)){
				 btn = false;
				 layer.msg("信息不能为空");
				 return false;
			 }
		 });
		 var employeeId = $("#affsort").val();
		 if(isNullOrEmpty(employeeId)){
			 layer.msg("请选择投诉对象");
			 btn = false;
			 return btn;
		 }
		 if(btn){
			 $.ajax({
	             type: "POST",
	             url:"${ctx}/advice/adviceSave.do",
	             data:$('#dataForm').serialize(),// 你的formid
	             error: function(request) {
	            	 	layer.alert("网络故障，请稍后再试!");
	             },
	             success: function(data) {
	 	           	if(data.status=="true"){
		 	           	layer.alert(data.msg, function(){
		 	           		window.location.href="${ctx}/shift/shiftList.do";
	           		    });
	 	           	}else{
	 	           		 layer.msg(data.msg);
	 	           	}
	             }
	         }); 
		 }
	});
});
function isNullOrEmpty(strVal){
	strVal = strVal.replace(/(^\s*)|(\s*$)/g,"");
	if(strVal == '' || strVal == null || strVal == undefined){
		return true;
	}else{
		return false;
	}
}
</script>
</body>
</html>